Field of the Invention
The present invention relates to an image processing apparatus and a method for controlling the image processing apparatus, and relates in particular to a technique for correcting a defective pixel.
Description of the Related Art
An image capture apparatus such as a digital camera takes an image using an image sensor such as a CMOS sensor. In general, a defective pixel exists in the image sensor since a large number of pixels are provided therein. As a technique for correcting the value of such a defective pixel, a method is known that uses a pixel value estimated from one or more values of one or more non-defective pixels existing at the periphery of the defective pixel, as the pixel value at a defective pixel position. Hereinafter, in the present specification, obtaining a pixel value at the defective pixel position that would have been obtained if the pixel were not defective will be referred to as defective pixel correction.
For example, Japanese Patent Laid-Open No. 11-220661 discloses a method in which values of peripheral pixels of the same color as the defective pixel are referenced, the shape of a subject near the defective pixel is classified into any of predetermined patterns, and the defective pixel is corrected by using peripheral pixels and a method that corresponds to the classified pattern. Japanese Patent Laid-Open No. 2005-175547 discloses a method that uses, when the spatial frequency of a subject near a defective pixel is high, adjoining pixels for detecting a reference direction of a pixel to be used in correction of the defective pixel, thereby realizing more accurate interpolation than in the case of using pixels of the same color as the defective pixel.
However, with the conventional techniques disclosed in the aforementioned patent documents, a defective pixel can be accurately corrected for a subject having a predetermined specific angle, but there are cases where erroneous correction occurs in the case of a subject having a different angle. For example, consider the case where a subject has an angle (here, approximately 27 degrees) that is close to horizontal, as shown in FIG. 16A. In FIG. 16A, a reference area of pixels used in correction of a defective pixel in the conventional techniques is denoted by a thick frame. Assuming that a pixel value at the defective pixel position is the value (0) shown in FIG. 16B, the defective pixel cannot be appropriately corrected with the value (30 or 40) of a pixel of the same color as the defective pixel within the reference area.
It is more likely that a pixel value suitable for correction of the defective pixel is found within the reference area by expanding the reference area. However, if, for example, pixel values of a subject having a repetitive pattern shown in FIG. 16C are as shown in FIG. 16D due to the defective pixel, there are cases where the angle of the subject cannot be correctly detected based on a difference between two points.